package com.net.shop.car.manager.ui.adapter;

import java.util.List;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.TextView;

import com.net.shop.car.manager.R;
import com.net.shop.car.manager.api.model.Area;

public class ProvinceAdapter extends BaseAdapter {

	private Context mContext;
	private List<Area> data;

	public ProvinceAdapter(Context mContext, List<Area> data) {
		super();
		this.mContext = mContext;
		this.data = data;
	}

	@Override
	public int getCount() {
		// TODO Auto-generated method stub
		return data.size();
	}

	@Override
	public Object getItem(int position) {
		// TODO Auto-generated method stub
		return position;
	}

	@Override
	public long getItemId(int arg0) {
		// TODO Auto-generated method stub
		return 0;
	}

	@Override
	public View getView(int position, View contentView, ViewGroup viewGroup) {
		// TODO Auto-generated method stub
		Area info = data.get(position);
		Holdler holdler;
		if (contentView == null) {
			contentView = LayoutInflater.from(mContext).inflate(R.layout.item_province, null);
			holdler = new Holdler();
			holdler.mTvProvinceName = (TextView) contentView.findViewById(R.id.province_name);
			contentView.setTag(holdler);
		} else {
			holdler = (Holdler) contentView.getTag();
		}
		holdler.mTvProvinceName.setText(info.getName());
		return contentView;
	}

	class Holdler {
		private TextView mTvProvinceName;
	}

}
